﻿using System;
using System.Collections.Generic;
using System.Linq;
using Sumen.Model.Model;

namespace Sumen.Business.Presenter.Category
{
    public class DiscountPresenter
    {


        public ICollection<discount> GetAll()
        {
            using (sumenEntities objEntities = new sumenEntities())
            {
                return objEntities.discounts.ToList();
            }
        }

        public discount GetById(object pId)
        {
            using (sumenEntities objEntities = new sumenEntities())
            {
                int id = Convert.ToInt32(pId);
                return objEntities.discounts.FirstOrDefault(p => p.Disc_ID == id);
            }
        }

        public discount GetByCustomerType(object pId)
        {
            using (sumenEntities objEntities = new sumenEntities())
            {
                int id = Convert.ToInt32(pId);
                return objEntities.discounts.FirstOrDefault(p => p.Disc_CUSTOMER_TYPE_ID == id && p.Disc_Actived == 1);
            }
        }


    }
}
